<html>
<head><meta charset="utf-8"><title>SSE and negative zero · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html">SSE and negative zero</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211800889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211800889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211800889">(Sep 30 2020 at 18:25)</a>:</h4>
<p>Is SSE expected to produce negative zero when negating a lane of 0f32?  I'm writing the tests and it doesn't appear to (but I would expect it to)</p>



<a name="211803992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211803992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211803992">(Sep 30 2020 at 18:50)</a>:</h4>
<p>It does on gcc, since it compiles to xoring each lane with 0x8000_0000:<br>
<a href="https://gcc.godbolt.org/z/aK81r3">https://gcc.godbolt.org/z/aK81r3</a></p>



<a name="211804230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211804230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211804230">(Sep 30 2020 at 18:52)</a>:</h4>
<p>Yeah, I definitely would have expected just an xorps.  Haven't inspected the asm yet.  <span class="user-mention" data-user-id="224471">@Lokathor</span> maybe this is why packed_simd multiplies by -1 instead of subtracts from 0?</p>



<a name="211804289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211804289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211804289">(Sep 30 2020 at 18:53)</a>:</h4>
<p>Hmm, we were using 0-vec, yeah.</p>
<p>I'd be fine with xor, but the mul I'm still unsure we'd get a good compile out of it</p>



<a name="211804325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211804325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211804325">(Sep 30 2020 at 18:53)</a>:</h4>
<p>Once I get the tests pushed we can address it</p>



<a name="211805669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805669">(Sep 30 2020 at 19:04)</a>:</h4>
<p>If we need to handle some arches specially to make sure the crate actually works with the correct performance, that's what we're gonna do.</p>



<a name="211805767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805767">(Sep 30 2020 at 19:05)</a>:</h4>
<p>though we should at least see what <code>* -1</code> compiles to if that is what works mathematically.</p>



<a name="211805849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805849">(Sep 30 2020 at 19:06)</a>:</h4>
<p>the xor also works mathematically</p>



<a name="211805867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805867">(Sep 30 2020 at 19:06)</a>:</h4>
<p>(deleted)</p>



<a name="211805868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805868">(Sep 30 2020 at 19:06)</a>:</h4>
<p>or like.. bittily</p>



<a name="211805883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211805883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211805883">(Sep 30 2020 at 19:06)</a>:</h4>
<p>yeah</p>



<a name="211806014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211806014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211806014">(Sep 30 2020 at 19:07)</a>:</h4>
<p>I've definitely relied on multiplying by -1 in the past, but in C++ on GCC for limited architectures :)</p>



<a name="211806245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211806245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211806245">(Sep 30 2020 at 19:09)</a>:</h4>
<p>Correctness first, optimization second, handling specific ISAs third, imo.</p>



<a name="211806406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211806406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211806406">(Sep 30 2020 at 19:11)</a>:</h4>
<p>I tend to agree. If someone is looking for incorrect but faster behavior they should probably use std::arch instead</p>



<a name="211806550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211806550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211806550">(Sep 30 2020 at 19:12)</a>:</h4>
<p>I would like us to have room for "incorrect but faster" but I definitely see our purview as satisfying Rust's requirements first, which are "correctness, mostly, or at least safety and control".</p>



<a name="211808174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211808174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211808174">(Sep 30 2020 at 19:26)</a>:</h4>
<p>xor is both correct and fast.</p>
<p>i initially said <code>0-vec</code> because it's correct for ints and i thought it was for floats too. the advantage was not needing two macro cases. Since it's not correct for floats we should probably keep <code>0-vec</code> for ints and use <code>vec^Self::splat(-0.0)</code> for floats.</p>



<a name="211808980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211808980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211808980">(Sep 30 2020 at 19:33)</a>:</h4>
<p>float subtraction triggers rounding, basically</p>



<a name="211810795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211810795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211810795">(Sep 30 2020 at 19:48)</a>:</h4>
<p>LLVM uses <code>-0.0 - x</code> for <code>-x</code>, though I think they're moving away from that.</p>



<a name="211811353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211811353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211811353">(Sep 30 2020 at 19:53)</a>:</h4>
<p>at the risk of sounding overly cynical: If their name isn't William Kahan, don't trust their float impl farther than you can test them.</p>



<a name="211812119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211812119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211812119">(Sep 30 2020 at 19:59)</a>:</h4>
<p>LLVM uses <code>-0.0 - x</code> for scalar neg too, so, either it's correct (which it is for the rounding mode LLVM assumes) or all code using fp neg compiled with LLVM is incorrect</p>



<a name="211813128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211813128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211813128">(Sep 30 2020 at 20:07)</a>:</h4>
<p>see <a href="https://gcc.godbolt.org/z/oTEjh9">https://gcc.godbolt.org/z/oTEjh9</a></p>



<a name="211813495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211813495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211813495">(Sep 30 2020 at 20:10)</a>:</h4>
<p>Kahan Or <del>Bust</del> Test. :^)</p>



<a name="211853038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/211853038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Horacio Hidalgo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#211853038">(Sep 30 2020 at 23:34)</a>:</h4>
<p>Hello!</p>



<a name="212454674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212454674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212454674">(Oct 06 2020 at 16:47)</a>:</h4>
<p>IEEE754-2019 (and IIRC earlier, but I only have 2019 on hand) explicitly says negate should only touch the sign bit, and that it's explicitly <em>not</em> the same as a subtraction (from 5.5.1 "Sign bit operations"):</p>
<blockquote>
<p><code>negate(x)</code> copies a floating-point operand x to a destination in the same format, reversing the sign bit. negate(x) is not the same as subtraction(0, x)</p>
</blockquote>
<p>It also says (when introducing negate/abs/copysign) a few lines earlier:</p>
<blockquote>
<p>The operations treat floating-point numbers and NaNs alike, and signal no exception. These operations may propagate non-canonical encodings.</p>
</blockquote>
<p>This is all to say that xor is the correct implementation here, and mul or subtraction (even with -0.0) is incorrect.</p>



<a name="212462213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212462213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212462213">(Oct 06 2020 at 17:53)</a>:</h4>
<p><code>-0.0 - x</code> is correct for the assumptions LLVM makes about floating-point types by default: always round-to-nearest-even, fp exceptions ignored, and no one cares about the difference between different NaN bit-patterns.</p>



<a name="212462302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212462302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212462302">(Oct 06 2020 at 17:54)</a>:</h4>
<p>yeah but xor_ps also has meaningfully lower latency on at least intel systems. i'll have a patch for this up shortly</p>



<a name="212462395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212462395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212462395">(Oct 06 2020 at 17:55)</a>:</h4>
<p>Did you check to make sure it doesn't optimize to xor_ps? I'm almost certain it will. In packed_simd it similarly used a multiply by -1, which should do the same</p>



<a name="212462522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212462522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212462522">(Oct 06 2020 at 17:56)</a>:</h4>
<p>i did, although i used _mm_foo intrinsics and not the simd ones</p>



<a name="212462799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212462799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212462799">(Oct 06 2020 at 17:58)</a>:</h4>
<p>llvm optimizes it to xorps:<br>
<a href="https://gcc.godbolt.org/z/MPa5Tf">https://gcc.godbolt.org/z/MPa5Tf</a></p>



<a name="212463348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463348">(Oct 06 2020 at 18:02)</a>:</h4>
<p>Interestingly, doesn't seem to optimize with <code>std::arch</code>: <a href="https://rust.godbolt.org/z/z7E8G6">https://rust.godbolt.org/z/z7E8G6</a></p>



<a name="212463401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463401">(Oct 06 2020 at 18:02)</a>:</h4>
<p>needs to be -0.0</p>



<a name="212463411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463411">(Oct 06 2020 at 18:02)</a>:</h4>
<p>whoops</p>



<a name="212463455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463455">(Oct 06 2020 at 18:03)</a>:</h4>
<p>dumb mistake, it does work: <a href="https://rust.godbolt.org/z/61zGY8">https://rust.godbolt.org/z/61zGY8</a></p>



<a name="212463499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463499">(Oct 06 2020 at 18:03)</a>:</h4>
<p>yeah, i just realized i had non-full optimization flags left  over in godbolt, which is why when i checked with _mm_foo it didn't seem to optimize it the way i'd hope</p>



<a name="212463862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463862">(Oct 06 2020 at 18:06)</a>:</h4>
<p>i think this transformation isn't legal on platforms that need to canonicalize values tho</p>



<a name="212463894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212463894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212463894">(Oct 06 2020 at 18:06)</a>:</h4>
<p>which might just be wasm for some nans</p>



<a name="212464044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212464044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212464044">(Oct 06 2020 at 18:08)</a>:</h4>
<p>i guess i can turn this patch into an float <code>abs</code> patch relatively easily, unless someone is already doing that.</p>



<a name="212464097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212464097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212464097">(Oct 06 2020 at 18:08)</a>:</h4>
<p>most of it is a bit of plumbing for to_bits/from_bits (which i didn't make pub, since idk if we actually want the way i did them)</p>



<a name="212482832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212482832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212482832">(Oct 06 2020 at 20:40)</a>:</h4>
<p>There's no reason <em>not</em> to use an xor that I'm seeing.</p>
<ul>
<li>It's absolutely correct</li>
<li>It requires less optimization so it's nicer in debug mode</li>
<li>It's closer to what the spec declares you should do.</li>
</ul>
<p>So we should just write it as xor and move on I think.</p>



<a name="212485337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212485337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212485337">(Oct 06 2020 at 21:02)</a>:</h4>
<p>interesting.</p>



<a name="212487213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212487213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212487213">(Oct 06 2020 at 21:18)</a>:</h4>
<blockquote>
<p>It requires less optimization so it's nicer in debug mode</p>
</blockquote>
<p>is there any hope that this will be okay at all in debug mode? i had been assuming no — core::arch is totally abysmal there, although i guess the reasons for this (e.g. <code>#[target_feature]</code>'s design preventing <code>#[inline(always)]</code> and such) don't apply here.</p>
<blockquote>
<p>There's no reason not to use an xor that I'm seeing.</p>
</blockquote>
<p>Yes, it's actually not really valid to do this with subtract (or multiply) since:</p>
<ul>
<li>
<p>those will raise invalid op for a sNaN argument  (not that anybody really cares). </p>
</li>
<li>
<p>any platform that requires canonicalization of floats using <code>sub</code> will (incorrectly) canonicalize the argument. I think this include wasm's NaN handling, but the usual example for canonicalization is: if you have the "flush subnormal numbers to zero" flag in your fpenv, then all subnormal numbers are treated as non-canonical representations of zeros. </p>
</li>
</ul>
<p>I think the default fpenv for (some?) 32 bit arm machines <em>does</em> flush denormals to zero in this way, so it's maybe worth checking on them</p>
<p>or just changing it to be xor, it's pretty clear that the float spec intends sign bit operation" (<code>copysign</code>/<code>abs</code>/<code>negate</code>) to all operate on the float's binary representation directly. It even calls out subtraction as invalid.</p>



<a name="212490689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212490689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212490689">(Oct 06 2020 at 21:52)</a>:</h4>
<p>I don't think we'll get <em>good</em> performance in debug mode, no. Rust's performance in debug mode is generally a complete joke.</p>



<a name="212490777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212490777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212490777">(Oct 06 2020 at 21:52)</a>:</h4>
<p>However, it's not unreasonable to keep an eye on things and at least try to lean towards what makes debug run well if it's the same either way in release mode.</p>



<a name="212492946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212492946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212492946">(Oct 06 2020 at 22:15)</a>:</h4>
<p>yeah, I suspect the current code is probably wrong for subnormals on arm32 because it doesn't use xor. trying to verify, but that means i need to figure out why cross is broken on my linux box or finally set up the raspberry pi i have in a box.</p>



<a name="212494320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494320">(Oct 06 2020 at 22:32)</a>:</h4>
<p>DO IT.</p>



<a name="212494339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494339">(Oct 06 2020 at 22:33)</a>:</h4>
<p>Team Raspi!</p>



<a name="212494350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494350">(Oct 06 2020 at 22:33)</a>:</h4>
<p>( actually what version of Raspi do you have? )</p>



<a name="212494517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494517">(Oct 06 2020 at 22:35)</a>:</h4>
<p>rpi4</p>



<a name="212494545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494545">(Oct 06 2020 at 22:35)</a>:</h4>
<p>oh I am pretty sure RPI4 is a full aarch64 platform</p>



<a name="212494611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494611">(Oct 06 2020 at 22:36)</a>:</h4>
<p>the OS is usually armv6 but</p>



<a name="212494966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212494966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212494966">(Oct 06 2020 at 22:40)</a>:</h4>
<p>that would determine both the target triple, and the initial fpcr value i think</p>



<a name="212495051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212495051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212495051">(Oct 06 2020 at 22:42)</a>:</h4>
<p>yeah I am just noting because I am not 100% sure of the semantics of running "aarch32" programs on aarch64!</p>



<a name="212495633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212495633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212495633">(Oct 06 2020 at 22:49)</a>:</h4>
<p>it looks like llvm does the right thing even though it's strictly speaking a miscompilation on that target. it seems to do the right thing even in debug builds, surprisingly, but if that ever stopped i suspect we'd have observably different behavior depending on optimization settings.</p>



<a name="212496123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212496123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212496123">(Oct 06 2020 at 22:57)</a>:</h4>
<p>you can get the raspi OS in both 32 bit modes and 64 bit modes, but their 64-bit OS is only intended for the rpi3 and rpi4, not the older models.</p>



<a name="212583802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212583802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212583802">(Oct 07 2020 at 16:24)</a>:</h4>
<p>with the changes in my CI patch, adding </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[test]</span><span class="w"></span>
<span class="cp">#[cfg_attr(target_arch = </span><span class="s">"wasm32"</span><span class="cp">, wasm_bindgen_test)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">neg_odd_floats</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">slice_chunks</span><span class="p">(</span><span class="o">&amp;</span><span class="n">C</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">expected</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">apply_unary_lanewise</span><span class="p">(</span><span class="n">v</span><span class="p">,</span><span class="w"> </span><span class="o">&lt;</span><span class="cp">$scalar</span><span class="o">&gt;</span>::<span class="n">neg</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_biteq</span><span class="o">!</span><span class="p">(</span><span class="o">-</span><span class="n">v</span><span class="p">,</span><span class="w"> </span><span class="n">expected</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>to the float ops tests causes a lot of platforms to fail unless we use xor for the negate. unfortunately, using xor for negate produces worse code on arm even in release builds...</p>



<a name="212583886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212583886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212583886">(Oct 07 2020 at 16:24)</a>:</h4>
<p>What about multiplying by -1?</p>



<a name="212583907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212583907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212583907">(Oct 07 2020 at 16:25)</a>:</h4>
<p>definitely invalid</p>



<a name="212583940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212583940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212583940">(Oct 07 2020 at 16:25)</a>:</h4>
<p>Just curious because that's what packed_simd does</p>



<a name="212583989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212583989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212583989">(Oct 07 2020 at 16:25)</a>:</h4>
<p>What's worse on arm, and what's failing on the other architectures?</p>



<a name="212584046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212584046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212584046">(Oct 07 2020 at 16:26)</a>:</h4>
<p>multiplying by negative one will canonicalize which is the same reason subtraction is wrong</p>



<a name="212584100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212584100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212584100">(Oct 07 2020 at 16:26)</a>:</h4>
<p>after the CI patch lands i'll put a patch up with just the failing test so you can see. it was a few things in various places</p>



<a name="212584202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212584202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212584202">(Oct 07 2020 at 16:27)</a>:</h4>
<p>worse on arm is using xor to do the bitflip instead of the appropriate f32 vector neg instruciton it happens to have</p>



<a name="212584586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212584586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212584586">(Oct 07 2020 at 16:30)</a>:</h4>
<p>Interesting</p>



<a name="212584706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212584706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212584706">(Oct 07 2020 at 16:31)</a>:</h4>
<p>honestly that was the only one i actually looked at, there were a lot of suprising failures, some of the platforms only failed in debug builds, others only in release. i was surprised that xor fixed all of these</p>



<a name="212585442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212585442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212585442">(Oct 07 2020 at 16:37)</a>:</h4>
<p>found the old CI run with just the test. there might be more wrong in the CI set up (all of the failures may not be because of this — but honestly it looks like most are): <a href="https://github.com/thomcc/stdsimd/runs/1220021695?check_suite_focus=true">https://github.com/thomcc/stdsimd/runs/1220021695?check_suite_focus=true</a></p>



<a name="212587808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212587808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212587808">(Oct 07 2020 at 16:56)</a>:</h4>
<p>If the outward API is consistent, there should be no problem with using internal conditional compilation to pick a specialized intrinsic on ARM or any other specific platform.</p>



<a name="212588061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212588061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212588061">(Oct 07 2020 at 16:58)</a>:</h4>
<p>Maybe we should just get Rustc to expose an intrinsic for LLVM's <code>fneg</code> instruction?</p>



<a name="212596666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212596666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212596666">(Oct 07 2020 at 18:05)</a>:</h4>
<p>LLVM sucking at something on a given platform just means we handroll more Rust code internally.</p>



<a name="212596718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212596718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212596718">(Oct 07 2020 at 18:05)</a>:</h4>
<p>yeah a simd_neg like the other fns in <a href="http://intrinsics.rs">intrinsics.rs</a> would solve this fine</p>



<a name="212596817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212596817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212596817">(Oct 07 2020 at 18:06)</a>:</h4>
<p>and yeah, if we can pester LLVM to do it Properly that's also fine.</p>



<a name="212597091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212597091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212597091">(Oct 07 2020 at 18:08)</a>:</h4>
<p>in the mean time the xor solution is correct everywhere tho, unlike sub/mul</p>



<a name="212601834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212601834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212601834">(Oct 07 2020 at 18:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero/near/212596817">said</a>:</p>
<blockquote>
<p>and yeah, if we can pester LLVM to do it Properly that's also fine.</p>
</blockquote>
<p>LLVM does it properly with a dedicated <code>fneg</code> instruction since a few releases ago. Rust (apparently) just doesn't expose that yet.</p>



<a name="212601932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212601932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212601932">(Oct 07 2020 at 18:46)</a>:</h4>
<p>Okay.<br>
Adding that to the compiler shouldn't be too hard.</p>



<a name="212605108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SSE%20and%20negative%20zero/near/212605108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SSE.20and.20negative.20zero.html#212605108">(Oct 07 2020 at 19:08)</a>:</h4>
<p>there's a PR up for the fix and I filed an issue for replacing it with an intrinsic later</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>